home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 June / PCWorld_2007-06_cd.bin / v cisle / tclock / tclocklight-040702-3.exe / source / property / pageformat2.c < prev    next >
C/C++ Source or Header  |  2004-02-01  |  3KB  |  108 lines

  1. /*-------------------------------------------------------------
  2.   pageformat2.c : "Detail of format" dialog
  3.   (C) Kazuto Sato 1997-2003
  4.   For the license, please read readme.txt.
  5.   
  6.   Written by Kazubon, Nanashi-san
  7. ---------------------------------------------------------------*/
  8.  
  9. #include "tcprop.h"
  10.  
  11. /* Globals */
  12.  
  13. BOOL CALLBACK DlgProcFormat2(HWND hDlg, UINT message,
  14.     WPARAM wParam, LPARAM lParam);
  15.  
  16. /* Statics */
  17.  
  18. static void OnInit(HWND hDlg, LPARAM lParam);
  19. static void OnOK(HWND hDlg);
  20.  
  21. /*------------------------------------------------
  22.    dialog procedure of "Detail of format"
  23. --------------------------------------------------*/
  24. BOOL CALLBACK DlgProcFormat2(HWND hDlg, UINT message,
  25.     WPARAM wParam, LPARAM lParam)
  26. {
  27.     switch(message)
  28.     {
  29.         case WM_INITDIALOG:
  30.             OnInit(hDlg, lParam);
  31.             return TRUE;
  32.         case WM_COMMAND:
  33.         {
  34.             WORD id; // , code;
  35.             id = LOWORD(wParam); // code = HIWORD(wParam);
  36.             switch (id)
  37.             {
  38.                 case IDOK: OnOK(hDlg); // fall through
  39.                 case IDCANCEL: EndDialog(hDlg, id);
  40.                     break;
  41.             }
  42.             return TRUE;
  43.         }
  44.     }
  45.     return FALSE;
  46. }
  47.  
  48. /*------------------------------------------------
  49.   initialize the dialog
  50. --------------------------------------------------*/
  51. void OnInit(HWND hDlg, LPARAM lParam)
  52. {
  53.     char s[80], s2[11];
  54.     int ilang, codepage;
  55.     
  56.     // common/tclang.c
  57.     SetDialogLanguage(hDlg, "Format2", g_hfontDialog);
  58.     
  59.     ilang = (int)lParam;
  60.     
  61.     // "AM Symbol" and "PM Symbol"
  62.     CBResetContent(hDlg, IDC_AMSYMBOL);
  63.     GetMyRegStr(NULL, "AMsymbol", s, 80, "");
  64.     if(s[0]) CBAddString(hDlg, IDC_AMSYMBOL, (LPARAM)s);
  65.     
  66.     codepage = GetCodePage(GetUserDefaultLangID());
  67.     
  68.     MyGetLocaleInfoA(ilang, codepage, LOCALE_S1159, s2, 10);
  69.     if(s2[0] && strcmp(s, s2) != 0)
  70.         CBAddString(hDlg, IDC_AMSYMBOL, (LPARAM)s2);
  71.     if(strcmp(s, "AM") != 0 && strcmp(s2, "AM") != 0)
  72.         CBAddString(hDlg, IDC_AMSYMBOL, (LPARAM)"AM");
  73.     if(strcmp(s, "am") != 0 && strcmp(s2, "am") != 0)
  74.         CBAddString(hDlg, IDC_AMSYMBOL, (LPARAM)"am");
  75.     CBSetCurSel(hDlg, IDC_AMSYMBOL, 0);
  76.     
  77.     CBResetContent(hDlg, IDC_PMSYMBOL);
  78.     GetMyRegStr(NULL, "PMsymbol", s, 80, "");
  79.     if(s[0]) CBAddString(hDlg, IDC_PMSYMBOL, (LPARAM)s);
  80.     MyGetLocaleInfoA(ilang, codepage, LOCALE_S2359, s2, 10);
  81.     if(s2[0] && strcmp(s, s2) != 0)
  82.         CBAddString(hDlg, IDC_PMSYMBOL, (LPARAM)s2);
  83.     if(strcmp(s, "PM") != 0 && strcmp(s2, "PM") != 0)
  84.         CBAddString(hDlg, IDC_PMSYMBOL, (LPARAM)"PM");
  85.     if(strcmp(s, "pm") != 0 && strcmp(s2, "pm") != 0)
  86.         CBAddString(hDlg, IDC_PMSYMBOL, (LPARAM)"pm");
  87.     CBSetCurSel(hDlg, IDC_PMSYMBOL, 0);
  88.     
  89.     CheckDlgButton(hDlg, IDC_ZERO,
  90.         GetMyRegLong("", "HourZero", FALSE));
  91. }
  92.  
  93. /*------------------------------------------------
  94.   "OK" button
  95. --------------------------------------------------*/
  96. void OnOK(HWND hDlg)
  97. {
  98.     char s[80];
  99.     
  100.     GetDlgItemText(hDlg, IDC_AMSYMBOL, s, 80);
  101.     SetMyRegStr("", "AMsymbol", s);
  102.     GetDlgItemText(hDlg, IDC_PMSYMBOL, s, 80);
  103.     SetMyRegStr("", "PMsymbol", s);
  104.     
  105.     SetMyRegLong("", "HourZero",
  106.         IsDlgButtonChecked(hDlg, IDC_ZERO));
  107. }
  108.